Completed
Push — master ( 3b47d6...befc32 )
by Sam
03:47
created

$(document).ready   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 16
rs 9.4285
c 0
b 0
f 0
cc 2
nc 2
nop 0
1
(function () {
2
    $(document).ready(function () {
3
4
        // Don't do anything if this isn't a Edit Counter page.
5
        if ($("body.ec").length === 0) {
6
            return;
7
        }
8
9
        // Set up charts.
10
        $(".chart-wrapper").each(function () {
11
            var chartType = $(this).data("chart-type");
12
            if ( chartType === undefined ) {
13
                return false;
14
            }
15
            var data = $(this).data("chart-data");
16
            var labels = $(this).data("chart-labels");
17
            var $ctx = $("canvas", $(this));
18
            new Chart($ctx, {
0 ignored issues
show
Unused Code Best Practice introduced by
The object created with new Chart($ctx, {Identif...e))))),false,false)))}) is not used but discarded. Consider invoking another function instead of a constructor if you are doing this purely for side effects.
Loading history...
Bug introduced by
The variable Chart seems to be never declared. If this is a global, consider adding a /** global: Chart */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
19
                type: chartType,
20
                data: {
21
                    labels: labels,
22
                    datasets: [ { data: data } ]
23
                }
24
            });
0 ignored issues
show
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
25
        });
26
27
        // Load recent global edits' HTML via Ajax, to not slow down the initial page load.
28
        var $latestGlobalContainer = $("#latestglobal-container");
29
        var url = xtBaseUrl + 'ec-latestglobal/'
0 ignored issues
show
Bug introduced by
The variable xtBaseUrl seems to be never declared. If this is a global, consider adding a /** global: xtBaseUrl */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
30
            + $latestGlobalContainer.data("project") + '/'
31
            + $latestGlobalContainer.data("username") + '?htmlonly=yes';
32
        $.ajax({
33
            url: url,
34
            timeout: 30000
35
        }).done(function (data) {
36
            $latestGlobalContainer.replaceWith(data);
37
        }).fail(function (data) {
0 ignored issues
show
Unused Code introduced by
The parameter data is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
38
        });
39
40
    });
41
} )();
42